package com.xjtu.chapter02;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author yjq
 * @version 1.0
 * @date 2021/8/6 16:27
 */
public class Ex2_ParseXXX {
    //通过BufferedReader实现从键盘读入各种数据类型，然后将其转换为基本数据类型
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        //读一个integer型数字
        System.out.print("输入integer:");
        int anInt = Integer.parseInt(in.readLine());
        System.out.println(anInt);

        //读一个float型数字
        System.out.print("输入float: ");
        float aFloat = Float.parseFloat(in.readLine());

        System.out.println(aFloat);
        //读一个double型数字
        System.out.print("输入double: ");
        double aDouble = Double.parseDouble(in.readLine());
        System.out.println(aDouble);

        //读一个字符串
        System.out.print("输入string: ");
        String aString = in.readLine();
        System.out.println(aString);
    }
}
